package controller

import (
	"GoAdmin/models"
	"github.com/gin-gonic/gin"
	"github.com/spf13/cast"
	"net/http"
	"strconv"
	"xorm.io/builder"
)

func CharList(c *gin.Context) {
	var (
		err error
	)
	page, _ := strconv.Atoi(c.DefaultPostForm("page", "1"))
	pageSize, _ := strconv.Atoi(c.DefaultPostForm("pageSize", "15"))
	offset := (page - 1) * pageSize
	filter := builder.NewCond()
	schoolId := c.PostForm("school_id")
	list, count, err := new(models.CharStandard).GetList(cast.ToInt64(schoolId), filter, pageSize, offset)
	if err != nil {
		c.JSON(http.StatusOK, gin.H{"code": 201, "msg": "fail"})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code": 200, "msg": "获取缴费类型列表成功", "data": map[string]interface{}{"list": list, "Count": count}})
	return
}
